let GameControl =require("GameControl");
cc.Class({
    extends: cc.Component,


    properties: {

        isAdd:true,
        squareScore:1,
        _rigid:{
            default:null,
            type:cc.RigidBody,
        },
        _box:{
            default:null,
            type:cc.PhysicsBoxCollider,
        },
        dropSpeed:100,

        addLength:100,
        SpeedTime:10,
    },


    start () {
        this._rigid= this.addComponent(cc.RigidBody);
        this._rigid.enabledContactListener =true;
        this._rigid.type=cc.RigidBodyType.Static;

        this._box= this.addComponent(cc.PhysicsBoxCollider);
        this._box.size.width =50;
        this._box.size.height =50;
        this._box.apply();
    },

    // 每次处理完碰撞体接触逻辑时被调用
    onPostSolve: function (contact, selfCollider, otherCollider) {

        GameControl.instance.scoreCtl.AddScore(this.squareScore);
        if(this.isAdd){
            GameControl.instance.BarCtl.AddLength(this.addLength,this.SpeedTime);
        }else
        {
            GameControl.instance.BarCtl.DelLength(this.addLength,this.SpeedTime);
        }



        this.Des();


    },

    Des(){
        this.node.destroy();
    },
    //(update(dt))
    UpdateFun(){

        this.node.y-=this.dropSpeed;
    },

    // update (dt) {},
});
